package com.charactereducation.api.controller;

import com.charactereducation.api.service.activity.ActivityServiceClient;
import com.charactereducation.module.vo.Activity;
import com.charactereducation.webcore.controller.BaseController;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by Baggio on 2018-6-25.
 */
@RestController
@RequestMapping("activity")
public class ActivityController extends BaseController {
    @Autowired
    ActivityServiceClient activityServiceClient;

    @GetMapping(value = "/{id}",produces = MediaType.APPLICATION_JSON_VALUE)
    public Activity getUserById(@PathVariable("id") Long id) {
        logger.info("getUserById");
        Activity activity = null;

            activity = activityServiceClient.getUserById(id);

        return activity;
    }




    @PostMapping(value = "/modify",produces = MediaType.APPLICATION_JSON_VALUE)
    public void modify() {
        Activity activity = (Activity) super.json2Obj(Activity.class);
        activityServiceClient.modify(activity);

    }
    @GetMapping(value = "/",produces = MediaType.APPLICATION_JSON_VALUE)
    public PageInfo activityList(@RequestParam Map<String, String> map) {
        logger.info("pageInfo===============>>>>>>>>>");
        PageInfo pageInfo = activityServiceClient.pageInfo(map);
        return pageInfo;
    }
}
